//手动实现clone方法
#[derive(Debug)]
struct Point {
    value: i32,
}

impl<'a> Clone for Point {
    fn clone(&self) -> Self {
        Self { value: self.value }
    }
}

//自动实现Clone，只需要在struct上加上 Clone特质
#[derive(Clone, Debug)]
#[allow(dead_code)]
struct Point2 {
    value: String,
}

fn main() {
    let s = Point { value: 12 };
    println!("{:?}", s.clone());
    //
    let d = Point2 {
        value: String::from("hi"),
    };
    let f = d.clone();
    println!("{:?}", f);
}
